// ============================================================================
// 文件管理模块样式
// - 文件管理、文件上传、图片上传组件的统一样式
// ============================================================================

@use '../base/variables' as *;

// ------------------------------
// 文件管理器样式
// ------------------------------

.file-manager {
  padding: 20px;

  // 上传按钮区域
  .upload-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #d9d9d9;

    .el-button {
      padding: 12px 24px;
      font-size: 14px;
    }
  }

  // 工具栏
  .toolbar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;

    .search-input {
      width: 300px;
      max-width: 100%;
    }
  }

  // 文件表格
  .file-cell {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .file-icon {
    font-size: 24px;
    margin-right: 12px;
    flex-shrink: 0;

    &.file-image {
      color: #67c23a;
    }

    &.file-video {
      color: #e6a23c;
    }

    &.file-audio {
      color: #909399;
    }

    &.file-document {
      color: #409eff;
    }
  }

  .file-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #e4e7ed;
    background-color: #fafafa;
  }

  .file-info {
    min-width: 0;
    flex: 1;
  }

  .file-name {
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .file-path {
    font-size: 12px;
    color: #909399;
  }

  // 分页
  .pagination-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
  }

  // 上传对话框
  .upload-dialog-content {
    padding: 20px 0;
  }

  // 预览对话框
  .preview-dialog :deep(.el-dialog__body) {
    padding: 20px;
  }

  .preview-container {
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .preview-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  }

  .preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #909399;
  }

  .preview-icon {
    font-size: 64px;
    margin-bottom: 16px;
  }

  .dialog-footer {
    text-align: center;
  }

  // 工具类
  .ml8 { 
    margin-left: 8px; 
  }
}

// ------------------------------
// 文件上传组件样式
// ------------------------------

.file-upload {
  width: 100%;

  // 手动上传控制按钮
  .upload-controls {
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #d9d9d9;
  }

  // 拖拽区域
  .drag-area {
    padding: 40px;
    text-align: center;
    border: 2px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.3s;

    &:hover {
      border-color: #409eff;
    }

    .el-icon--upload {
      font-size: 48px;
      color: #c0c4cc;
      margin-bottom: 16px;
    }

    .el-upload__text {
      color: #606266;
      font-size: 14px;

      em {
        color: #409eff;
        font-style: normal;
      }
    }

    .el-upload__tip {
      color: #909399;
      font-size: 12px;
      margin-top: 8px;
    }
  }

  // 自定义文件列表样式
  .custom-file-list {
    margin-top: 16px;

    .file-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px;
      border: 1px solid #e4e7ed;
      border-radius: 6px;
      margin-bottom: 8px;
      background: #fff;
      transition: all 0.3s;

      &:hover {
        background: #f5f7fa;
      }

      &.is-uploading {
        background: #f0f9ff;
        border-color: #409eff;
      }
    }

    .file-info {
      display: flex;
      align-items: center;
      flex: 1;
      min-width: 0;
    }

    .file-icon {
      font-size: 20px;
      color: #606266;
      margin-right: 12px;
      flex-shrink: 0;
    }

    .file-details {
      min-width: 0;
      flex: 1;
    }

    .file-name {
      font-size: 14px;
      color: #303133;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-bottom: 4px;
    }

    .file-size {
      font-size: 12px;
      color: #909399;
    }

    .file-actions {
      display: flex;
      align-items: center;
      flex-shrink: 0;
      margin-left: 12px;
    }

    .progress {
      width: 100px;
    }

    .action-buttons {
      display: flex;
      gap: 4px;
    }

    .remove-btn {
      color: #f56c6c;

      &:hover {
        background: #fef0f0;
      }
    }
  }
}

// ------------------------------
// 图片上传组件样式
// ------------------------------

.image-upload {
  width: 100%;

  // 手动上传控制按钮
  .upload-controls {
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #d9d9d9;
  }

  // 上传网格
  .upload-grid {
    display: grid;
    gap: 16px;
  }

  // 图片项
  .image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e4e7ed;
    background: #fff;

    &.is-uploading {
      border-color: #409eff;
    }

    .image-preview {
      position: relative;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
      }
    }

    .upload-progress {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: rgba(255, 255, 255, 0.9);
      border-radius: 50%;
      padding: 10px;
    }

    .image-actions {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.3s;

      .action-buttons {
        display: flex;
        gap: 8px;
      }
    }

    &:hover .image-actions {
      opacity: 1;
    }

    .upload-error {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(245, 108, 108, 0.9);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: white;
      font-size: 12px;
    }

    .image-info {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
      color: white;
      padding: 8px;
      font-size: 12px;

      .image-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 2px;
      }

      .image-size {
        opacity: 0.8;
      }
    }
  }

  // 上传占位符
  .upload-placeholder {
    border: 2px dashed #d9d9d9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.3s;
    background: #fafafa;

    &:hover:not(.is-disabled) {
      border-color: #409eff;
    }

    &.is-disabled {
      cursor: not-allowed;
      opacity: 0.5;
    }

    .upload-content {
      text-align: center;
      color: #8c939d;

      .upload-icon {
        font-size: 28px;
        margin-bottom: 8px;
      }

      .upload-text {
        font-size: 12px;
      }
    }
  }

  .el-upload__tip {
    color: #909399;
    font-size: 12px;
    margin-top: 8px;
  }

  // 预览对话框样式
  .image-preview-dialog :deep(.el-dialog__body) {
    padding: 20px;
  }

  .preview-container {
    text-align: center;

    img {
      max-width: 100%;
      max-height: 70vh;
      object-fit: contain;
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
  }

  .dialog-footer {
    text-align: center;
  }
}

// ------------------------------
// 响应式设计
// ------------------------------

@media (max-width: 768px) {
  .file-manager {
    padding: 12px;
    
    .upload-buttons {
      flex-direction: column;
      align-items: stretch;

      .el-button {
        width: 100%;
        justify-content: center;
      }
    }
    
    .toolbar {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;

      .search-input {
        width: 100%;
      }
    }
  }

  .image-upload {
    .upload-grid {
      grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
  }
}

// ------------------------------
// 打印样式
// ------------------------------

@media print {
  .file-manager {
    .upload-buttons,
    .toolbar,
    .pagination-wrapper {
      display: none !important;
    }
  }
}
